package cn.calm.entity;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.TableGenerator;
import javax.persistence.Transient;

import cn.calm.commons.entity.BaseEntity;

@Entity
@Table(name = "t_linksource")
public class LinkSource implements BaseEntity {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	@Id
	@TableGenerator(name = "SEQ", table = "sequence", pkColumnName = "KEYID", valueColumnName = "KEYVALUE", pkColumnValue = "LINK_SOURCE_ID",allocationSize=1)
	@GeneratedValue(strategy = GenerationType.AUTO, generator = "SEQ")
	private Integer id;
	private String path;
	/**
	 * 
	 */
	private Integer sourceType;
	public static final int JAVASCRIPT = 0, CSS = 1;
	private transient String sourceTypeName;
	private Integer disOrder;
//	private String deleteClass;
	private String description;
	public LinkSource() {
	}

	/**
	 * @param sourceType
	 *            the sourceType to set
	 */
	public void setSourceType(Integer sourceType) {
		this.sourceType = sourceType;
	}

	/**
	 * @return the sourceType
	 */
	public Integer getSourceType() {
		return sourceType;
	}

	/**
	 * @param disOrder
	 *            the disOrder to set
	 */
	public void setDisOrder(Integer disOrder) {
		this.disOrder = disOrder;
	}

	/**
	 * @return the disOrder
	 */
	public Integer getDisOrder() {
		return disOrder;
	}

	/**
	 * @param sourceTypeName
	 *            the sourceTypeName to set
	 */
	public void setSourceTypeName(String sourceTypeName) {
		this.sourceTypeName = sourceTypeName;
	}

	/**
	 * @return the sourceTypeName
	 */
	@Transient
	public String getDisplaySourceType() {
		if (sourceType == null) {
			return "";
		}
		switch (sourceType) {
		case CSS:
			return "CSS";
		case JAVASCRIPT:
			return "JAVASCRIPT";
		}
		return sourceTypeName;
	}

	@Override
	@Transient
	public Object getValue() {
		return getId();
	}

	@Override
	@Transient
	public String getDisplayName() {
		return "资源文件";
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getPath() {
		return path;
	}

	public void setPath(String path) {
		this.path = path;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}
}
